package com.ruoyi.project.men.api;


import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bootdo.R;
import com.ruoyi.project.men.service.MenSolutionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * 解决方案
 */
@Controller
@RequestMapping("/api/solution")
public class ApiMenSolutionController {

    @Autowired
    private MenSolutionService menSolutionService;


    /**
     *
     * @param params 获取解决方案图片和名字
     * @return
     */
    @PostMapping( "/getSolutionImgurlList")
    @ResponseBody
    public R getSolutionImgurlList(@RequestBody Map<String, Object> params){

        try{
            return menSolutionService.getSolutionImgurlList(params);
        }catch (Exception e){
            return R.error("服务器网络异常");
        }
    }

    /***
     * 解决方案详情
     * @param params  solutionId
     * @return
     */
    @PostMapping( "/getSolutionInfo")
    @ResponseBody
    public R getSolutionInfo(@RequestBody Map<String, Object> params){


        try{
            if (!params.containsKey("solutionId") || StringUtils.isBlank(params.get("solutionId").toString())

            ) {
                return R.error("参数错误");
            }
            return menSolutionService.getSolutionInfo(params);
        }catch (Exception e){
            return R.error("服务器网络异常");
        }
    }
}
